package com.zhongshengnetwork.rightbe.wzt.activity;

import android.content.DialogInterface;
import android.content.Intent;
//import android.support.annotation.NonNull;
//import android.support.v7.app.AppCompatActivity;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.RefreshState;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.BezierRadarHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wang.avi.AVLoadingIndicatorView;
import com.zhongshengnetwork.rightbe.Constant.APIKey;
import com.zhongshengnetwork.rightbe.Constant.Constant;
import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.R;
import com.zhongshengnetwork.rightbe.common.AppThemeUtils;
import com.zhongshengnetwork.rightbe.common.CommonUtils;
import com.zhongshengnetwork.rightbe.common.GsonTools;
import com.zhongshengnetwork.rightbe.common.ScreenUtils;
import com.zhongshengnetwork.rightbe.common.TopBarView;
import com.zhongshengnetwork.rightbe.common.activity.AppBaseActivity;
import com.zhongshengnetwork.rightbe.common.customview.CustomDialog;
import com.zhongshengnetwork.rightbe.common.utils.ToastUtil;
import com.zhongshengnetwork.rightbe.gsonmodel.CommonModel;
import com.zhongshengnetwork.rightbe.gsonmodel.LangInfoModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuContentDetailModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuInfoDetailModel;
import com.zhongshengnetwork.rightbe.https.HttpCallBack;
import com.zhongshengnetwork.rightbe.https.HttpsUtils;
import com.zhongshengnetwork.rightbe.lang.activity.LangPublishActivity;
import com.zhongshengnetwork.rightbe.wzt.model.WZTUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class WZTListActivity extends AppBaseActivity implements TopBarView.onTitleBarClickListener{

    private static final int REQUEST_SEARCH = 5002;
    private TopBarView topbar;
    private String title;
    private int opType = 0; //操作类型：1- 发布微纸条内容；2-选择微纸条 3-发布微纸条内容
    private String id;
    private final int linecount = 3;
    public String userid = null;
    private String dataContent = null;
    public int dataType = 1000;
    private int pageindex = 0;
    private int imgW = 0;
    private static final int Records = 20;
    private boolean isGetting = false;
    private boolean isHasMore = false;
    private List<WeiShuInfoDetailModel> list;
    private ListView listview;
    private MyAdapter adapter;
    //加载动画
    private AVLoadingIndicatorView avi;
    private RefreshLayout mRefreshLayout;

    private RelativeLayout search_top;
    private ImageView no_data_img;

    private boolean isPublish = false;
    private boolean isHome = false;
    private int dataId = 0;
    private WeiShuContentDetailModel weiShuContentDetailModel;
    private boolean fromsearch = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fromsearch = getIntent().getBooleanExtra("fromsearch", false);
        setContentView(R.layout.activity_wztlist);
        avi = (AVLoadingIndicatorView)findViewById(R.id.avi);

        weiShuContentDetailModel =  (WeiShuContentDetailModel) getIntent().getSerializableExtra("model");

        opType = getIntent().getIntExtra("opType", 0);
        id = getIntent().getStringExtra("id");

        title = getIntent().getStringExtra("title");
        dataType = getIntent().getIntExtra("dataType",1000);

        isHome = getIntent().getBooleanExtra("isHome", false);
        dataId = getIntent().getIntExtra("dataId", 0);

        topbar = (TopBarView)findViewById(R.id.topbar);
        topbar.getRightView().setVisibility(View.GONE);
        topbar.setClickListener(this);
        topbar.getTitleView().setText(title);
        topbar.getTitleView().setClickable(true);
        topbar.getTitleView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (list != null && list.size() > 0){
                    //listview.smoothScrollToPosition(0);
                    listview.setSelection(0);
                }
            }
        });

        topbar.getRightTextView().setText("分类");
        topbar.getRightTextView().setTextSize(16);
        topbar.getRightTextView().setTextColor(getResources().getColor(R.color.mainColor));
        topbar.getRightTextView().setClickable(true);
        topbar.getRightTextView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(WZTListActivity.this, ClassifyActivity.class);
                intent.putExtra("title", "分类推荐");
                intent.putExtra("dataType", 1);
                startActivity(intent);
            }
        });
        if (fromsearch == false){
            topbar.getRightView().setVisibility(View.GONE);
        }else {
            topbar.getRightTextView().setVisibility(View.GONE);
            topbar.getRightView().setImageResource(R.drawable.searchicon);
            topbar.getRightView().setVisibility(View.VISIBLE);
        }
        if (dataType == 8 || dataType == 0){//喜欢和订阅
            topbar.getRightView().setVisibility(View.GONE);
            topbar.getRightTextView().setVisibility(View.GONE);
            topbar.getRightView().setImageResource(R.drawable.searchicon);
        }

        pageindex = 0;
        if (list == null){
            list = new ArrayList<WeiShuInfoDetailModel>();
            int width = ScreenUtils.getScreenWidth(WZTListActivity.this);
            float density = ScreenUtils.getScreenDensity(WZTListActivity.this);
            imgW = (int) ((width-40*density)/linecount);
        }
        listview=(ListView) findViewById(R.id.wzt_listview);
        adapter=new MyAdapter();
        listview.setAdapter(adapter);

        no_data_img = (ImageView)findViewById(R.id.no_data_img);
        mRefreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
        //设置 Header 为 贝塞尔雷达 样式
        mRefreshLayout.setRefreshHeader(new BezierRadarHeader(WZTListActivity.this).setEnableHorizontalDrag(true));//BezierRadarHeader
        //设置 Footer 为 球脉冲 样式
        mRefreshLayout.setRefreshFooter(new ClassicsFooter(WZTListActivity.this).setSpinnerStyle(SpinnerStyle.Scale));//BallPulseFooter ClassicsFooter
        mRefreshLayout.setEnableRefresh(true);//启用刷新
        mRefreshLayout.setEnableLoadMore(true);//启用加载
        //刷新
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                //refreshlayout.finishRefresh();
                pageindex = 0;
                getData();
            }
        });
        mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //refreshLayout.finishLoadMore();
                getData();
            }
        });

        search_top = (RelativeLayout) findViewById(R.id.search_top);
        search_top.setClickable(true);
        search_top.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (fromsearch == true){
                    finish();
                    return;
                }
                Intent intent = new Intent(WZTListActivity.this, WZTSearchActivity.class);
                intent.putExtra("isResult",true);
                intent.putExtra("dataType", dataType);
                startActivityForResult(intent, REQUEST_SEARCH);
            }
        });
        mRefreshLayout.autoRefresh();

        RelativeLayout wztlist_layout = (RelativeLayout) findViewById(R.id.wztlist_layout);
        wztlist_layout.setBackgroundColor(AppThemeUtils.getInstance().getBackgroundColor());
        listview.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
        listview.setDivider(new ColorDrawable(AppThemeUtils.getInstance().getMainColor()));
        listview.setDividerHeight(0);//AppThemeUtils.DividerHeight
        search_top.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
        RelativeLayout search_shape_layout = (RelativeLayout) findViewById(R.id.search_shape_layout);
        search_shape_layout.setBackgroundResource(AppThemeUtils.getInstance().getSearchBackground());

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_SEARCH && resultCode == RESULT_OK){
            if (data != null) {
                final String content = data.getStringExtra("content");
                if (!CommonUtils.isEmpty(content)){
                    title = content;
                    dataContent = content;
                    if (dataType != 1001){
                        topbar.getTitleView().setText(title);
                        if (isHome == false){
                            if (dataType != 0 && dataType != 8){
                                dataType = 1000;
                            }

                        }
                    }
                    mRefreshLayout.autoRefresh();
                }
            }
        }
    }

    private void getData(){
        if (listview == null){
            return;
        }
        if (isGetting == true){
            return;
        }
        isGetting = true;

        new Thread(){
            @Override
            public void run() {
                super.run();
                final HashMap<String, String> map = new HashMap<String, String>();
                String url = "weishu/theme/find/list.do";
                map.put(APIKey.tokenKey, CommonUtils.formatString(CustomApplication.loginModel.getToken()));
                map.put("pageIndex",pageindex+"");
                map.put("pageRecord",Records+"");

                if (isHome == true){
                    url = "weishu/home/list.do";
                    map.put("dataId", dataId+"");
                    map.put("dataContent", CommonUtils.formatString(dataContent));
                }else {
                    if (!CommonUtils.isEmpty(title) && title.equals("微纸条") == false){
                        map.put("dataContent", CommonUtils.formatString(title));
                    }
                }
                if (opType == 3){
                    url = "weishu/theme/user/list.do";

                }else {
                    map.put("dataType",dataType+"");
                }

                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {

                        isGetting = false;
                        CommonModel commonModel = GsonTools.getCommonModel(data);
                        if (commonModel.getFlag().equals("1")){
                            final List<WeiShuInfoDetailModel> l = GsonTools.getWeiShuInfoDetailModel(data);
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (mRefreshLayout.getState() == RefreshState.Loading){
                                        //listview.stopLoadMore();
                                        mRefreshLayout.finishLoadMore();
                                    }else {
                                        list.clear();
                                        //listview.stopRefresh(true);
                                        mRefreshLayout.finishRefresh();
                                    }
                                    if (l != null && l.size() > 0){
                                        no_data_img.setVisibility(View.INVISIBLE);
                                        if (l.size() >= Records){
                                            //listview.setPullLoadEnable(true);
                                            mRefreshLayout.setEnableLoadMore(true);
                                        }else {
                                            //listview.setPullLoadEnable(false);
                                            mRefreshLayout.setEnableLoadMore(false);
                                        }
                                        list.addAll(l);
                                    }else {
                                        isHasMore = false;
                                        //listview.setPullLoadEnable(false);
                                        mRefreshLayout.setEnableLoadMore(false);
                                    }
                                    adapter.notifyDataSetChanged();
                                    if (pageindex == 0){
                                        //listview.smoothScrollToPosition(0);
                                        listview.setSelection(0);
                                    }
                                    if (l != null && l.size() > 0){
                                        pageindex += 1;
                                    }
                                }
                            });
                        }else {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (mRefreshLayout.getState() == RefreshState.Loading){
                                        //listview.stopLoadMore();
                                        mRefreshLayout.finishLoadMore();
                                    }else {
                                        list.clear();
                                        //listview.stopRefresh(true);
                                        mRefreshLayout.finishRefresh();
                                    }
                                    CustomApplication.showTip(commonModel, WZTListActivity.this);
                                }
                            });

                        }

                    }

                    @Override
                    public void onError(String msg) {
                        isGetting = false;
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (mRefreshLayout.getState() == RefreshState.Loading){
                                    //listview.stopLoadMore();
                                    mRefreshLayout.finishLoadMore();
                                }else {
                                    mRefreshLayout.finishRefresh();
                                }
                            }
                        });
                    }
                });
            }
        }.start();

    }

    /**
     * 点击了返回导航按钮
     */
    @Override
    public void onBackClick() {
        //Toast.makeText(LangDetailActivity.this, "你点击了左侧按钮", Toast.LENGTH_LONG).show();
        finish();
    }

    /**
     * 点击了右边导航按钮
     */
    @Override
    public void onRightClick() {
        finish();
    }

    private class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            int count = list.size()/linecount;
            if (list.size()%linecount > 0){
                count += 1;
            }
            return count;
        }


        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public boolean isEnabled(int position) {
            // TODO Auto-generated method stub
            return super.isEnabled(position);
        }

        /**
         * @param position
         * @param convertView
         * @param parent
         * @return
         */
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            //convertView的复用
            if (convertView == null) {
                convertView = View.inflate(WZTListActivity.this, R.layout.wzt_listview_item,null);
            }
            View view=convertView;

            LinearLayout wzt_layout_1 = (LinearLayout) view.findViewById(R.id.wzt_layout_1);
            LinearLayout wzt_layout_2 = (LinearLayout) view.findViewById(R.id.wzt_layout_2);
            LinearLayout wzt_layout_3 = (LinearLayout) view.findViewById(R.id.wzt_layout_3);

            ImageView wzt_img1 = (ImageView) view.findViewById(R.id.wzt_img1);
            ImageView wzt_read_icon_1 = (ImageView) view.findViewById(R.id.wzt_read_icon_1);
            TextView wzt_readcount_1 = (TextView) view.findViewById(R.id.wzt_readcount_1);
            TextView private_text_1 = (TextView) view.findViewById(R.id.private_text_1);
            TextView wzt_text1 = (TextView) view.findViewById(R.id.wzt_text1);


            ImageView wzt_img2 = (ImageView) view.findViewById(R.id.wzt_img2);
            ImageView wzt_read_icon_2 = (ImageView) view.findViewById(R.id.wzt_read_icon_2);
            TextView wzt_readcount_2 = (TextView) view.findViewById(R.id.wzt_readcount_2);
            TextView private_text_2 = (TextView) view.findViewById(R.id.private_text_2);
            TextView wzt_text2 = (TextView) view.findViewById(R.id.wzt_text2);

            ImageView wzt_img3 = (ImageView) view.findViewById(R.id.wzt_img3);
            ImageView wzt_read_icon_3 = (ImageView) view.findViewById(R.id.wzt_read_icon_3);
            TextView wzt_readcount_3 = (TextView) view.findViewById(R.id.wzt_readcount_3);
            TextView private_text_3 = (TextView) view.findViewById(R.id.private_text_3);
            TextView wzt_text3 = (TextView) view.findViewById(R.id.wzt_text3);


            wzt_img1.setVisibility(View.GONE);
            wzt_read_icon_1.setVisibility(View.GONE);
            wzt_readcount_1.setVisibility(View.GONE);
            private_text_1.setVisibility(View.GONE);
            wzt_text1.setVisibility(View.GONE);

            wzt_img2.setVisibility(View.GONE);
            wzt_read_icon_2.setVisibility(View.GONE);
            wzt_readcount_2.setVisibility(View.GONE);
            private_text_2.setVisibility(View.GONE);
            wzt_text2.setVisibility(View.GONE);

            wzt_img3.setVisibility(View.GONE);
            wzt_read_icon_3.setVisibility(View.GONE);
            wzt_readcount_3.setVisibility(View.GONE);
            private_text_3.setVisibility(View.GONE);
            wzt_text3.setVisibility(View.GONE);

            LinearLayout wzt_listview_item_layout = (LinearLayout) view.findViewById(R.id.wzt_listview_item_layout);
            wzt_listview_item_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            wzt_text1.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
            wzt_text2.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
            wzt_text3.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
            wzt_img1.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            wzt_img2.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            wzt_img3.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());

            int num = 0;
            int count = linecount*position;
            if (list.size()-count >= linecount){
                num = linecount;
            }else {
                while (list.size()-count > 0){
                    num+=1;
                    count+=1;
                }
            }
            int index = linecount*position;
            RequestOptions options = new RequestOptions().error(R.drawable.defaultbg).bitmapTransform(new RoundedCorners(Constant.CornerRadius));//图片圆角
            for (int i = 0; i < num; i++){
                WeiShuInfoDetailModel model = list.get(index+i);
                if (i == 0){
                    wzt_img1.setVisibility(View.VISIBLE);
                    wzt_readcount_1.setVisibility(View.VISIBLE);
                    wzt_text1.setVisibility(View.VISIBLE);
                    wzt_read_icon_1.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img1.getLayoutParams();
                    params.width =imgW;
                    params.height = imgW;
                    wzt_img1.setLayoutParams(params);
                    params = wzt_text1.getLayoutParams();
                    params.width = imgW;
                    wzt_text1.setLayoutParams(params);
                    if (WZTListActivity.this != null){
                        try {
                            Glide.with(WZTListActivity.this).load(model.getCover()).apply(options).placeholder(R.drawable.defaultbg).dontAnimate().into(wzt_img1);
                        }catch (Exception e){
                            LangPublishActivity.uploadError("微纸条列表加载图片报错："+e.getLocalizedMessage());
                        }
                    }
                    wzt_text1.setText(model.getTitle());
                    wzt_readcount_1.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_1.setVisibility(View.VISIBLE);
                    }
                    wzt_layout_1.setTag(index+i);
                    wzt_layout_1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });
                }else if (i == 1){
                    wzt_img2.setVisibility(View.VISIBLE);
                    wzt_readcount_2.setVisibility(View.VISIBLE);
                    wzt_text2.setVisibility(View.VISIBLE);
                    wzt_read_icon_2.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img2.getLayoutParams();
                    params.width =imgW;
                    params.height = imgW;
                    wzt_img2.setLayoutParams(params);
                    params = wzt_text2.getLayoutParams();
                    params.width = imgW;
                    wzt_text2.setLayoutParams(params);

                    if (WZTListActivity.this != null){
                        try {
                            Glide.with(WZTListActivity.this).load(model.getCover()).apply(options).placeholder(R.drawable.defaultbg).dontAnimate().into(wzt_img2);
                        }catch (Exception e){
                            LangPublishActivity.uploadError("微纸条列表加载图片报错："+e.getLocalizedMessage());
                        }
                    }
                    wzt_text2.setText(model.getTitle());
                    wzt_readcount_2.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_2.setVisibility(View.VISIBLE);
                    }
                    wzt_layout_2.setTag(index+i);
                    wzt_layout_2.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });
                }else if (i == 2){
                    wzt_img3.setVisibility(View.VISIBLE);
                    wzt_readcount_3.setVisibility(View.VISIBLE);
                    wzt_text3.setVisibility(View.VISIBLE);
                    wzt_read_icon_3.setVisibility(View.VISIBLE);
                    ViewGroup.LayoutParams params = wzt_img3.getLayoutParams();
                    params.width =imgW;
                    params.height = imgW;
                    wzt_img3.setLayoutParams(params);
                    params = wzt_text3.getLayoutParams();
                    params.width = imgW;
                    wzt_text3.setLayoutParams(params);

                    if (WZTListActivity.this != null){
                        try {
                            Glide.with(WZTListActivity.this).load(model.getCover()).apply(options).placeholder(R.drawable.defaultbg).dontAnimate().into(wzt_img3);
                        }catch (Exception e){
                            LangPublishActivity.uploadError("微纸条列表加载图片报错："+e.getLocalizedMessage());
                        }
                    }
                    wzt_text3.setText(model.getTitle());
                    wzt_readcount_3.setText(CommonUtils.getDisplayCount(model.getRealcount()));
                    if (model.getVisible() == false){
                        private_text_3.setVisibility(View.VISIBLE);
                    }
                    wzt_layout_3.setTag(index+i);
                    wzt_layout_3.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            onClickItem(v);
                        }
                    });
                }
            }
            return view;
        }
    }

    private void onClickItem(View v){
        if (isPublish == true){
            return;
        }
        int index = (int)v.getTag();
        if (list == null || index >= list.size()){
            return;
        }
        WeiShuInfoDetailModel model = list.get(index);
        if (opType == 1){
            //发布微纸条内容
            isPublish = true;
            avi.show();
            final HashMap<String, String> map = new HashMap<String, String>();
            String url = "weishu/content/weiju/publish.do";
            map.put(APIKey.tokenKey, CommonUtils.formatString(CustomApplication.loginModel.getToken()));
            map.put("weijuId", model.getId()+"");
            map.put("id", id);
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    isPublish = false;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            avi.hide();
                            CommonModel commonModel = GsonTools.getCommonModel(data);
                            if (commonModel.getFlag().equals("1")){
                                ToastUtil.show(WZTListActivity.this, "发布成功");
                                Intent intent = new Intent(WZTListActivity.this, WZTActivity.class);
                                Bundle bundle=new Bundle();
                                bundle.putSerializable("model", model);//序列化
                                intent.putExtras(bundle);//发送数据
                                startActivity(intent);
                            }else {
                                CustomApplication.showTip(commonModel, WZTListActivity.this);
                            }
                        }
                    });
                }

                @Override
                public void onError(String msg) {
                    isPublish = false;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            avi.hide();
                            ToastUtil.show(WZTListActivity.this, "发布失败，请稍后重试~");
                        }
                    });
                }
            });
        }else if (opType == 2){
            //选择微纸条
            Intent intent = new Intent();
            intent.putExtra("weijuId",model.getId()+"");
            intent.putExtra("title",model.getTitle());
            setResult(RESULT_OK, intent);
            finish();
        }else if (opType == 3){
            if (weiShuContentDetailModel != null){
                Intent intent = new Intent(WZTListActivity.this, WZTActivity.class);
                Bundle bundle=new Bundle();
                bundle.putSerializable("model", model);//序列化
                bundle.putSerializable("content", weiShuContentDetailModel);//序列化
                intent.putExtras(bundle);//发送数据
                intent.putExtra("isPublish", true);
                startActivity(intent);
                finish();
            }else {
                Intent intent = new Intent(WZTListActivity.this, WZTActivity.class);
                Bundle bundle=new Bundle();
                bundle.putSerializable("model", model);//序列化
                intent.putExtras(bundle);//发送数据
                intent.putExtra("isPublish", true);
                startActivity(intent);
            }
        }else {
            /*
            Intent intent = new Intent(WZTListActivity.this, WZTActivity.class);
            Bundle bundle=new Bundle();
            bundle.putSerializable("model", model);//序列化
            intent.putExtras(bundle);//发送数据
            startActivity(intent);
            */
            WZTUtils.goToWZT(WZTListActivity.this, model);
        }
    }

}
